package com.apps.java.Lambda;

public class AddableDemo {
    public static void main(String[] args) {

        //调用useAddable
        Addable a = new AddableImpl();
        useAddable(a);

        //匿名内部类
        useAddable(new Addable() {
            @Override
            public int add(int x, int y) {
                return x - y;
            }
        });

        //Lambda表达式
        useAddable((int x, int y) -> {
            return x * y;
        });

    }

    public static void useAddable(Addable a) {
        int num = a.add(20, 50);
        System.out.println(num);
    }
}
